import Vue from 'vue'
import { Message } from 'element-ui'
import { formatTime } from '@/utils/index'
import moment from 'moment'

Vue.prototype.$notifySuccess = function(msg, func) {
  Message({
    message: msg,
    type: 'success',
    duration: 2000,
    onClose: func
  })
}
Vue.prototype.$notifyWarning = function(msg, func) {
  Message({
    message: msg,
    type: 'warning',
    duration: 2000,
    onClose: func
  })
}
Vue.prototype.$notifyError = function(msg, func) {
  Message({
    message: msg,
    type: 'error',
    duration: 2000,
    onClose: func
  })
}

Vue.filter('formatDate', function(value) {
  return formatTime(value)
})

Vue.filter('formatDate2', function(value) {
  return moment(value).format('YYYY-MM-DD HH:mm:ss')
})

Vue.prototype.$target = 'http://localhost:3000'

moment.locale('zh-cn')
Vue.prototype.$moment = moment
